package com.swak.jna.posix;

import java.nio.ByteBuffer;

import com.sun.jna.Native;
import com.sun.jna.Platform;

public interface LibC {

	@SuppressWarnings("deprecation")
	LibC INSTANCE = (LibC) Native.loadLibrary(Platform.isWindows() ? "msvcrt" : "c", LibC.class);

	int chmod(CharSequence filename, int mode);

	int fchmod(int fd, int mode);

	int chown(CharSequence filename, int user, int group);

	int fchown(int fd, int user, int group);

	String getenv(CharSequence envName);

	int getegid();

	int setegid(int egid);

	int geteuid();

	int seteuid(int euid);

	int getgid();

	String getlogin();

	int setgid(int gid);

	int getpgid();

	int getpgid(int pid);

	int setpgid(int pid, int pgid);

	int getpgrp();

	int setpgrp(int pid, int pgrp);

	int getppid();

	int getpid();

	int setpwent();

	int endpwent();

	int setgrent();

	int endgrent();

	int getuid();

	int setsid();

	int setuid(int uid);

	int kill(int pid, int signal);

	int kill(long pid, int signal);

	int dup(int fd);

	int dup2(int oldFd, int newFd);

	int fcntl(int fd, int fnctl);

	int fcntl(int fd, int fnctl, int arg);

	int fcntl(int fd, int fnctl, int... arg);

	int access(CharSequence path, int amode);

	int getdtablesize();

	public interface LibCSignalHandler {
		void signal(int sig);
	}

	long signal(int sig, LibCSignalHandler handler);

	int raise(int raise);

	int lchmod(CharSequence filename, int mode);

	int lchown(CharSequence filename, int user, int group);

	int link(CharSequence oldpath, CharSequence newpath);

	int mkdir(CharSequence path, int mode);

	int rmdir(CharSequence path);

	int symlink(CharSequence oldpath, CharSequence newpath);

	int readlink(CharSequence oldpath, ByteBuffer buffer, int len);

	int readlink(CharSequence path, byte[] buffer, int len);

	int setenv(CharSequence envName, CharSequence envValue, int overwrite);

	int unsetenv(CharSequence envName);

	int fork();

	int waitpid(long pid, int[] status, int options);

	int wait(int[] status);

	int getpriority(int which, int who);

	int setpriority(int which, int who, int prio);

	long read(int fd, byte[] dst, long len);

	long write(int fd, byte[] src, long len);

	long read(int fd, ByteBuffer dst, long len);

	long write(int fd, ByteBuffer src, long len);

	long pread(int fd, byte[] dst, long len, long offset);

	long pwrite(int fd, byte[] src, long len, long offset);

	long pread(int fd, ByteBuffer dst, long len, long offset);

	long pwrite(int fd, ByteBuffer src, long len, long offset);

	int read(int fd, byte[] dst, int len);

	int write(int fd, byte[] src, int len);

	int read(int fd, ByteBuffer dst, int len);

	int write(int fd, ByteBuffer src, int len);

	int pread(int fd, byte[] dst, int len, int offset);

	int pwrite(int fd, byte[] src, int len, int offset);

	int pread(int fd, ByteBuffer dst, int len, int offset);

	int pwrite(int fd, ByteBuffer src, int len, int offset);

	long lseek(int fd, long offset, int whence);

	int close(int fd);

	int execv(CharSequence path, CharSequence[] argv);

	int execve(CharSequence path, CharSequence[] argv, CharSequence[] envp);

	int chdir(CharSequence path);

	int flock(int fd, int mode);

	int unlink(CharSequence path);

	int open(CharSequence path, int flags, int perm);

	int pipe(int[] fds);

	int truncate(CharSequence path, long length);

	int ftruncate(int fd, long offset);

	int rename(CharSequence oldName, CharSequence newName);

	long getcwd(byte[] cwd, int len);

	int gethostname(ByteBuffer buffer, int len);

	int fsync(int fd);

	int fdatasync(int fd);

	int socketpair(int domain, int type, int protocol, int[] fds);

	int setsockopt(int s, int level, int optname, ByteBuffer optval, int optlen);

	int syscall(int number);

	int syscall(int number, int arg1);

	int syscall(int number, int arg1, int arg2);

	int syscall(int number, int arg1, int arg2, int arg3);

	int daemon(int nochdir, int noclose);

	int getgroups(int size, int[] groups);

	String nl_langinfo(int item);

	String setlocale(int category, String locale);

	String strerror(int errno);

}
